
<!DOCTYPE html>  
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo $title?></title>
    <link href="<?php // Set CSS based on site view, user post and user profile css is choosen by the user itself.
    				if(isset($_GET['id']) || isset($_GET['usrName'])){
    					$user -> getUserTheme((isset($_GET['id']))? $_GET['id'] : $_GET['usrName']);
					}else{
						$user -> getUserTheme(false);
					} 
				?>" rel="stylesheet" type="text/css" media="all" />
	 <script type="text/javascript">
        window.onload = function() {
			// Get a reference to the loggin-link
			var a = document.getElementById("loggin");
			//Set code to run when the link is clicked
			a.onclick = function() {
				// Show logg in form
				document.getElementById('logginform').style.display = 'block';
				return false; // Do not redirect
			}
        }
    </script>
  	
<?php if($title == "Rediger innlegg" || $title == "Nytt innlegg"){?>
	<script type="text/javascript" src="include/tinymce/js/tinymce/tinymce.min.js"></script>
	<script type="text/javascript">
	tinymce.init({
		selector: "textarea",
	   		//plugins
		plugins: [
	          "advlist autolink lists link image charmap print preview anchor",
	          "searchreplace visualblocks code",
	          "insertdatetime media table contextmenu paste jbimages"
	        ],
	        image_list: "media/listImg.php?id=<?php echo $user -> getUserID()?>",
	            //toolbar
	        toolbar:  " undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
	  		relative_urls: false,
	    	height : 400
		});
	</script>
<?php }else if(isset($_POST['loginName'])&& $user -> userLoggedOn()){
			header( "Location: displayUsr.php?usrName={$user -> userName}" );
}?>
</head>    
<body>
    <div id='wrapper'>
    
    <header>
        <h1><a href='index.php' title='Startside'>EEBS.NO</a></h1>
		<?php if($user->userLoggedOn()) {
			echo "<p>Logget inn som <b>".$user->userName."</b></p>";
		} ?>
    </header>
    <nav>
        <ul id="mainnav">
	    <li><a href="index.php" title="Startside">Startside</a></li>
	    <li><a href="statistics.php" title="Topplister">Topplister</a></li>
	</ul>
    
    <?php if(!$user ->userLoggedOn()){?>    
	<ul id="usernav">
	    <li><a href="newUser.php" title="Registrer ny bruker">Registrer</a></li>
	    <li><a id="loggin" href="#" title="Logg inn">Logg inn</a></li>
	</ul>
	<?php }else{?>
	<ul id="usernav">
		<li><a id="loggin" href="#" title="Logg ut">Logg ut</a></li>
		<?php echo "<li><a href='displayUsr.php?usrName=".$user->userName."' title='";
		echo($user->isUserAdmin())? "Administrator'>Administrator</a></li>":"Min blogg'>Min blogg</a></li>";
		?>
	</ul>
	<?php }?>
    </nav>
    
    <div id="main">
		<div id="logginform" style="display:none">
			<?php echo $user->getLoginForm(); ?>
		</div>